home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / checkbox / plugins / launchpad_report.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-10-12  |  5.3 KB  |  132 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import posixpath
  5. import shutil
  6. from checkbox.lib.safe import safe_make_directory
  7. from checkbox.properties import Path
  8. from checkbox.plugin import Plugin
  9. from checkbox.reports.launchpad_report import LaunchpadReportManager
  10.  
  11. class LaunchpadReport(Plugin):
  12.     filename = Path(default = '%(checkbox_data)s/submission.xml')
  13.     stylesheet = Path(default = '%(checkbox_share)s/report/checkbox.xsl')
  14.     
  15.     def register(self, manager):
  16.         super(LaunchpadReport, self).register(manager)
  17.         self._report = {
  18.             'summary': {
  19.                 'private': False,
  20.                 'contactable': False,
  21.                 'live_cd': False },
  22.             'hardware': { },
  23.             'software': {
  24.                 'packages': [] },
  25.             'questions': [],
  26.             'context': [] }
  27.         self._manager.reactor.call_on('report', self.report, 100)
  28.         for rt, rh in [
  29.             ('report-architecture', self.report_architecture),
  30.             ('report-client', self.report_client),
  31.             ('report-datetime', self.report_datetime),
  32.             ('report-distribution', self.report_distribution),
  33.             ('report-dmi', self.report_context),
  34.             ('report-hal', self.report_hal),
  35.             ('report-modprobe', self.report_context),
  36.             ('report-modules', self.report_context),
  37.             ('report-packages', self.report_packages),
  38.             ('report-pci', self.report_context),
  39.             ('report-processors', self.report_processors),
  40.             ('report-sysctl', self.report_context),
  41.             ('report-system_id', self.report_system_id),
  42.             ('report-results', self.report_results)]:
  43.             self._manager.reactor.call_on(rt, rh)
  44.         
  45.  
  46.     
  47.     def report_architecture(self, architecture):
  48.         self._report['summary']['architecture'] = architecture
  49.  
  50.     
  51.     def report_hal(self, hal):
  52.         self._report['hardware']['hal'] = hal
  53.  
  54.     
  55.     def report_client(self, client):
  56.         self._report['summary']['client'] = client
  57.  
  58.     
  59.     def report_datetime(self, datetime):
  60.         self._report['summary']['date_created'] = datetime
  61.  
  62.     
  63.     def report_distribution(self, distribution):
  64.         self._report['software']['lsbrelease'] = dict(distribution)
  65.         self._report['summary']['distribution'] = distribution.distributor_id
  66.         self._report['summary']['distroseries'] = distribution.release
  67.  
  68.     
  69.     def report_packages(self, packages):
  70.         self._report['software']['packages'].extend(packages)
  71.  
  72.     
  73.     def report_processors(self, processors):
  74.         self._report['hardware']['processors'] = processors
  75.  
  76.     
  77.     def report_system_id(self, system_id):
  78.         self._report['summary']['system_id'] = system_id
  79.  
  80.     
  81.     def report_results(self, results):
  82.         for result in results:
  83.             test = result.test
  84.             question = dict(test.attributes)
  85.             question['command'] = str(test.command)
  86.             question['description'] = str(test.description)
  87.             question['requires'] = str(test.requires)
  88.             question['result'] = dict(result.attributes)
  89.             self._report['questions'].append(question)
  90.         
  91.  
  92.     
  93.     def report_context(self, sources):
  94.         if not isinstance(sources, list):
  95.             sources = [
  96.                 sources]
  97.         
  98.         for source in sources:
  99.             if isinstance(source, tuple):
  100.                 source = source[1]
  101.             
  102.             info = { }
  103.             if 'command' in dir(source):
  104.                 info['command'] = source.command
  105.             
  106.             if 'filename' in dir(source):
  107.                 info['command'] = source.filename
  108.             
  109.             if 'directory' in dir(source):
  110.                 info['command'] = source.directory
  111.             
  112.             info['data'] = str(source)
  113.             self._report['context'].append(info)
  114.         
  115.  
  116.     
  117.     def report(self):
  118.         stylesheet = posixpath.join(posixpath.dirname(self.filename), posixpath.basename(self.stylesheet))
  119.         shutil.copy(self.stylesheet, stylesheet)
  120.         stylesheet = posixpath.abspath(stylesheet)
  121.         report_manager = LaunchpadReportManager('system', '1.0', stylesheet)
  122.         payload = report_manager.dumps(self._report).toprettyxml('')
  123.         directory = posixpath.dirname(self.filename)
  124.         safe_make_directory(directory)
  125.         file = open(self.filename, 'w')
  126.         file.write(payload)
  127.         file.close()
  128.         self._manager.reactor.fire('exchange-report', self.filename)
  129.  
  130.  
  131. factory = LaunchpadReport
  132.